ComponentOne Reports for WPF
Task Based Help / Working with Report Fields / Loading Custom fields
In This Topic
    Loading Custom fields
    In This Topic

    Reports for WPF allow users to load reports that contain custom fields by using the CustomFields assembly. Reports created by the C1ReportDesigner application offers following custom fields:

    Note that some custom fields, such as those listed below, need additional ComponentOne assemblies to be referenced:

    The following sample creates the report definition with Chart custom field, loads, and renders it to C1DocumentViewer in WPF application; the steps  are illustrated as follows:

    1. Create the report definition:
      1. Open the C1ReportDesigner application. For more information on how to access the C1ReportDesigner, see Accessing C1ReportDesigner from Visual Studio.
      2. Create a new report by using C1Report Wizard. Set the Employees table in C1NWind.mdb as the data source, select the fields, and set the report name as "Chart".
      3. Click the Design button to begin editing the report.
      4. In the Custom Fields group of the Insert tab, click the Chart button.
      5. Place the Chart field in your report and resize the field to show the chart.
      6. From the Properties window, set the properties of the Chart field as following:
        • DataX: Country
        • DataY: EmployeeID
        • Aggregate: Count
        • ChartType: Column
        • YMin: 0
      7. Preview the report by pressing F5.
      8. Save the report definition file with the file name "ChartField.xml". The design view of the report definition is as shown:
    2. Create the WPF application:
      1. Create a new WPF application. In order to access C1NWind.mdb, set the project's platform target to x86.
      2. Add following assemblies to the References in the project:
        • C1.WPF.C1Report.CustomFields
        • C1.WPF.C1Report
        • C1.WPF
        • C1.Win.C1Chart
      3. Add the report definition file ChartField.xml into the project folder. Set its 'Copy to Output Directory' property to 'Copy if newer'.
      4. Add C1DocumentViewer control into the MainWindow.
      5. In the code view, add the following code:
        C#
        Copy Code
        public MainWindow()
                {
                    InitializeComponent();
                    var report = new C1.C1Report.C1Report();
                    report.Load("ChartField.xml", "Chart");
                    this.c1DocumentViewer.Document = report.C1Document.FixedDocumentSequence;
                }
        
        VB
        Copy Code
        Public Sub New()
            InitializeComponent()
            Dim report = New C1.C1Report.C1Report()
            report.Load("ChartField.xml", "Chart")
            Me.c1DocumentViewer.Document = report.C1Document.FixedDocumentSequence
        End Sub
        
    3. Run the application. You see the report with custom field rendered in the C1DocumentViewer as shown: 
    For more information on creating chart custom field, see the Adding Chart Fields topic. The report definition CustomFields.xml available in the default location C:\Users\Windows 8.1\Documents\ComponentOne Samples\Studio for WPF\C1.WPF.C1Report\C1WPFReport\XML\CommonTasks\ contains all the custom fields.
    From 2015v2 onwards, for WPF applications referencing C1.WPF.C1Report.CustomFields.4 dll, please add C1.Win.4 and C1.Win.Barcode.4 dlls to your projects.
    See Also